<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
    <meta name="description" content="">
    <meta name="author" content="">

    <title>登录</title>

    <!-- Bootstrap core CSS-->
    <link href="/static/vendor/bootstrap/css/bootstrap.min.css" rel="stylesheet">
    <!-- Custom fonts for this template-->
    <link href="/static/vendor/font-awesome/css/font-awesome.min.css" rel="stylesheet" type="text/css">
    <!-- Custom styles for this template-->
    <link href="/static/css/sb-admin/sb-admin.css" rel="stylesheet">
    <!--<script type="text/javascript" src="http://qzonestyle.gtimg.cn/qzone/openapi/qc_loader.js" data-appid="1106904136" data-redirecturi="https://www.laifuzhi.cn/api/qq" charset="utf-8"></script>-->
</head>

<body class="bg-dark">
<div class="container">
    <div id="errorMessage" class="alert alert-danger alert-dismissible fade show card-login mt-5 mx-auto" role="alert" style="display:none">
        <button type="button" class="close" data-dismiss="alert" aria-label="Close">
            <span aria-hidden="true">&times;</span>
        </button>
    </div>
    <div class="card card-login mx-auto mt-5">
        <div class="card-header">肥肥小浣熊</div>
        <div class="card-body">
            <form id="loginForm">
                <div class="form-group">
                    <label for="id_username">用户名</label>
                    <input class="form-control" id="id_username" type="text" aria-describedby="emailHelp"
                           placeholder="Username" name="username">
                </div>
                <div class="form-group">
                    <label for="id_password">密码</label>
                    <input class="form-control" id="id_password" type="password" placeholder="Password" name="password">
                </div>
                <div class="form-group">
                    <div class="form-check">
                        <label class="form-check-label">
                            <input class="form-check-input" type="checkbox" name="rememberMe" id="remember_me">记住密码</label>
                    </div>
                </div>
                <a id="id_user_login_submit" class="btn btn-primary btn-block">登录</a>
            </form>
            <div class="container text-center mt-3">
                <div class="row">
                    <a class="d-block small col-sm offset-6" href="/static/html/register.html">现在注册</a>
                    <a class="d-block small col-sm" href="#">忘记密码</a>
                </div>
            </div>
            <!--<label class="form-check-label" style="float: right">第三方登录：-->
                <!--<span id="qqLoginBtn"></span>-->
                <!--<script type="text/javascript">-->
                    <!--QC.Login({-->
                        <!--btnId:"qqLoginBtn"    //插入按钮的节点id-->
                    <!--});-->
                <!--</script>-->
            <!--</label>-->

        </div>
    </div>
</div>
<!-- Bootstrap core JavaScript-->
<script src="/static/vendor/jquery/jquery.min.js"></script>
<script src="/static/vendor/bootstrap/js/bootstrap.bundle.min.js"></script>
<!-- Core plugin JavaScript-->
<script src="/static/vendor/jquery-easing/jquery.easing.min.js"></script>
<script>
    $(document).ready(function () {
        $("#id_user_login_submit").click(function () {
            $.post('/api/login',{username:$('#id_username').val(),password:$('#id_password').val(),rememberMe:$('#remember_me').prop('checked')},function (result) {
                if (result.code===0) {
                    $(location).attr('href', '/');
                } else if (result.code===2) {
                    $('#errorMessage').text('您已有账号登录').show();
                } else {
                    $('#errorMessage').text('用户名或密码错误').show();
                }
            }).fail(function () {
                alert('网络异常，请重试');
            });
        });
    });
</script>
</body>

</html>
